<!DOCTYPE html>
<?

function kekata($x) {

    $x = abs($x);

    $angka = array("", "satu", "dua", "tiga", "empat", "lima",
        "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");

    $temp = "";



    if ($x < 12) {

        $temp = " " . $angka[$x];
    } else if ($x < 20) {

        $temp = kekata("$x – 10") . " belas";
    } else if ($x < 100) {

        $temp = kekata($x / 10) . " puluh" . kekata($x % 10);
    } else if ($x < 200) {

        $temp = " seratus" . kekata("$x – 100");
    } else if ($x < 1000) {

        $temp = kekata($x / 100) . " ratus" . kekata($x % 100);
    } else if ($x < 2000) {

        $temp = " seribu" . kekata("$x – 1000");
    } else if ($x < 1000000) {

        $temp = kekata($x / 1000) . " ribu" . kekata($x % 1000);
    } else if ($x < 1000000000) {

        $temp = kekata($x / 1000000) . " juta" . kekata($x % 1000000);
    } else if ($x < 1000000000000) {

        $temp = kekata($x / 1000000000) . " milyar" . kekata(fmod($x, 1000000000));
    } else if ($x < 1000000000000000) {

        $temp = kekata($x / 1000000000000) . " trilyun" . kekata(fmod($x, 1000000000000));
    }

    return $temp;
}

function terbilang($x, $style=4) {

    if ($x < 0) {

        $hasil = "minus " . trim(kekata($x));
    } else {

        $hasil = trim(kekata($x));
    }

    switch ($style) {

        case 1:

            $hasil = strtoupper($hasil);

            break;

        case 2:

            $hasil = strtolower($hasil);

            break;

        case 3:

            $hasil = ucwords($hasil);

            break;

        default:

            $hasil = ucfirst($hasil);

            break;
    }

    return $hasil;
}

function tanggal($format, $nilai="now") {
    $en = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Jan", "Feb",
        "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    $id = array("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu",
        "Jan", "Feb", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September",
        "Oktober", "November", "Desember");
    return str_replace($en, $id, date($format, strtotime($nilai)));
}
?>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>cetak</title>
        <link href="<?php echo base_url(); ?>css/bootstrap.min.css" rel="stylesheet" media="screen"/>
        <link href="<?php echo base_url(); ?>css/bootstrap.min.css" rel="stylesheet" media="print"/>
        <script type="text/javascript">
            function cetak(){
                window.print();
                return false;
            }
        </script>
        <style type="text/css" media="print">
            body{
                margin: 30px 50px 30px 100px;
                padding: 10px;
            }
            
            .logo{
                visibility: hidden;
            }
        </style>
        <style type="text/css">

            .tot{
                border-top: 1px solid black;
                border-bottom: 1px solid black;
                width: 300px;
                padding: 10px;
            }
            
            #line{
                margin-top: 20px;
                border-top: 1px solid black;
            }
            
            .tt{
                height: 100px;
            }
            
            .rupe{
                margin-left: 265px;
            }
            
            .logo{
                visibility: hidden;
            }
        </style>
    </head>
    <body>
        <div id="cetak" class="container">
            <div class="row">
                <img class="logo" src="<?php echo base_url('img/logo.png'); ?>" alt=""/>
                <span class="clearfix"></span>
                <span class="offset5 span3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $invoice; ?></span>
                <h2>&nbsp;</h2> 
                <span class="span3">&nbsp;</span><span class="span3 under">&nbsp;&nbsp;<?php echo $consgnee; ?></span>
                <span class="clearfix"></span>
                <span class="span3">&nbsp;</span><span class="span3 under">&nbsp;&nbsp;<?php echo terbilang($penerimaan)." Rupiah"; ?></span>
                <span class="clearfix"></span>
                <span class="span3">&nbsp;</span><span class="span3 under">&nbsp;&nbsp;<?php echo $description; ?></span>
                <span class="clearfix"></span>
                <span class="span3">&nbsp;</span><span class="span3 under">&nbsp;&nbsp;<?php echo "ex ".$origin." by ".$via; ?></span>
                <br /><br />
                <div>
                    <br />
                    <p><span class="rupe"><?php echo $penerimaan.",-"; ?></span> </p>
                </div>
                
                <div class="offset5">
                    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo tanggal("j M Y"); ?> </p>
                </div>
            </div>
        </div>

    </body>
</html>